package com.bhprod.comatule.detail;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.bhprod.comatule.model.Species;

public class SpeciesDetailAdapter extends FragmentStatePagerAdapter {

	private Species species;
	private Context context;

	public SpeciesDetailAdapter(FragmentManager fm, Context context) {
		super(fm);
		this.context = context;
	}

	@Override
	public Fragment getItem(int position) {
		SpeciesDetailFragment fragment = new SpeciesDetailFragment();
		fragment.setPhoto(species.getPhotos().get(position));
		fragment.setContext(context);
		
		if (position - 1 >= 0) {
			fragment.setSiblingMinusOne(true);
		}
//		if (position - 2 >= 0) {
//			fragment.setSiblingMinusTwo(true);
//		}
		if (position + 1 < getCount()) {
			fragment.setSiblingPlusOne(true);
		}
//		if (position + 2 < getCount()) {
//			fragment.setSiblingPlusTwo(true);
//		}
		
		return fragment;
	}
	
	@Override
	public int getCount() {
		return species.getPhotos().size();
	}

	public Species getSpecies() {
		return species;
	}

	public void setSpecies(Species species) {
		this.species = species;
	}

}
